package sctu.edu.java.year2016.team01.lishuai.day20160521.chapter4_3;


/**
 * Created by ���˧ on 2016/5/21.
 * ��whileѭ����1+1/2��+1/3��+....+1/20��)�ĺ�
 */
public class Sun {
    static double g(int n)
    {
        double f=0;
        if(n<0)
            System.out.println("error");
        else if(n==0||n==1)
            f=1;
        else
            f = g(n-1)*n;
        return f;
    }
    public static void main(String[] args) {

        double sum = 0;
        int i=1;
        while(i<=20)
        {
            sum=sum+1/g(i++);
        }
        System.out.println("1+1/2!+1/3!....1/20!="+sum);

    }
}